package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.saas.domain.dao.CustomerFocusDao;
import com.xbongbong.saas.domain.entity.CustomerFocusEntity;
import com.xbongbong.saas.model.CustomerFocusModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/2/16 22:43
 * @since v1.0
 */
@Service
public class CustomerFocusModelImpl implements CustomerFocusModel {
    @Resource
    private CustomerFocusDao customerFocusDao;

    @Override
    public CustomerFocusEntity getByKey(Long key, String corpid) {
        return customerFocusDao.getByKey(key, corpid);
    }

    @Override
    public Integer insert(CustomerFocusEntity entity) throws XbbException {
        return customerFocusDao.insert(entity);
    }

    @Override
    public Integer update(CustomerFocusEntity entity) throws XbbException {
        return customerFocusDao.update(entity);
    }

    @Override
    public List<CustomerFocusEntity> findEntitys(Map<String, Object> param) {
        return customerFocusDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return customerFocusDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public CustomerFocusEntity getByCustomerId(Long dataId, String userId, String corpid) {
        return customerFocusDao.getByCustomerId(dataId,userId,corpid);
    }

    @Override
    public List<Long> getNoShareCustomerIdList(String userId, String corpid) {
        return customerFocusDao.getNoShareCustomerIdList(userId,corpid);
    }

    @Override
    public List<Long> getShareCustomerIdList(String corpid) {
        return customerFocusDao.getShareCustomerIdList(corpid);
    }

    @Override
    public Long save(CustomerFocusEntity customerFocusEntity) throws XbbException{
        if (customerFocusEntity.getId() == null){
            insert(customerFocusEntity);
        }else {
            update(customerFocusEntity);
        }
        return customerFocusEntity.getId();
    }

    @Override
    public void unFocusBatch(List<Long> dataIdList, String corpid) {
        customerFocusDao.unFocusBatch(dataIdList,corpid);
    }

    @Override
    public void unFocusByUserIdIn(Long customerId, String corpid, List<String> userIdIn) {
        customerFocusDao.unFocusByUserIdIn(customerId,corpid, userIdIn);
    }

    @Override
    public void batchUnFocus(List<Long> customerIdIn, String corpid, List<String> userIdIn) {
        customerFocusDao.batchUnFocus(customerIdIn,corpid, userIdIn);
    }

    @Override
    public void unFocus(Long customerId, String corpid, String userId) {
        customerFocusDao.unFocus(customerId,corpid,userId);
    }

    @Override
    public Integer deleteBatch(List<Long> idIn, String corpid) {
        return customerFocusDao.deleteBatch(idIn, corpid);
    }
}
